# -*- coding: utf-8 -*-
import os
from openpyxl import load_workbook

"""
实现功能：
    学位英语pdf匹配
    可根据excel指定行匹配文件是否存在
"""
look_up_table_row_start = 3
look_up_table_row_number = 56
id_list = []
os_id_list = []
look_up_table_path = 'D:/02_item/01_社会化英语上报/05_2024秋季/01_学位证/20240909/s026凭学位证书免修学位外语情况汇总表.xlsx'
look_up_table_excel = load_workbook(look_up_table_path)
look_up_table_all_sheet = look_up_table_excel.get_sheet_names()
look_up_table_sheet = look_up_table_excel.get_sheet_by_name(look_up_table_all_sheet[0])
j = 0
for i in range(look_up_table_row_start, look_up_table_row_number):
    student_id = look_up_table_sheet.cell(i, 7).value
    id_list.append(student_id)
    if os.path.exists('D:/02_item/01_社会化英语上报/05_2024秋季/01_学位证/20240909/' + student_id):
        print(student_id + '文件存在')
        j = j + 1
    else:
        print(student_id + '文件不存在')

path = 'D:/02_item/01_社会化英语上报/05_2024秋季/01_学位证/20240909/'
files = os.listdir(path)
for file in files:
    if 'pdf' in file:
        os_id_list.append(file)

difference = set(id_list).symmetric_difference(set(os_id_list))

print(difference)
